package com.jlcindia.spring.dao;

import org.springframework.orm.hibernate3.HibernateTemplate;

import org.hibernate.LockMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.jlcindia.hibernate.*;
import com.jlcindia.to.*;;

public class HibernateStudentDAO implements StudentDAO{
	
	@Autowired
	HibernateTemplate hibernateTemplate = null;
	
	public void addStudent(Student stu){
		hibernateTemplate.save(stu);
	}
	
	
	public StudentTO getStudentBySid(int sid) {
		Object obj = hibernateTemplate.get(Student.class,new Integer(sid),LockMode.READ);
		StudentTO sto = null;
		if(obj!=null){
			Student stu = (Student)obj;
			sto = new StudentTO();
			sto.setSid(stu.getSid());
			sto.setSname(stu.getSname());
			sto.setSname(stu.getEmail());
			sto.setPhone(stu.getPhone());
		}
		return sto;
	}


	@Override
	public StudentTO getStudentBySid(String sid) {
		// TODO Auto-generated method stub
		return null;
	}

}

